//
//  YDYFindViewController.m
//  DY_Bilibili
//
//  Created by 杨德勇 on 2016/10/24.
//  Copyright © 2016年 杨德勇. All rights reserved.
//

#import "YDYFindViewController.h"
#import "JCTagListView.h"
#import "YDYNetWorkTool.h"
#import <NSObject+MJKeyValue.h>
#import "YDYSearchModel.h"
@interface YDYFindViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITextField *searchTF;
@property (weak, nonatomic) IBOutlet UIView *tagView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *tagViewHeightLC;
@property (weak, nonatomic) IBOutlet UITableView *tableView;
/** 搜索区域的数据源 */
@property (nonatomic, strong) NSArray *searchTags;
@end

@implementation YDYFindViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self loadData];
    [self setupUI];
    
//    self.view.backgroundColor = [UIColor redColor];
//    
//    JCTagListView *aaa = [[JCTagListView alloc]init];
//    [aaa setCompletionBlockWithSelected:^(NSInteger index) {
//        self.view.backgroundColor = YDYRandomColor;
//    }];
//    
//    aaa.frame = CGRectMake(50, 50, 300, 300);
//    NSMutableArray *arr = [NSMutableArray array];
//    for (int i = 0; i < 20; i++) {
//        NSString *str = [NSString stringWithFormat:@"aa-%d",i];
//        [arr addObject:str];
//    }
//    aaa.tags = arr;
//    
//    NSMutableArray *arr2 = [NSMutableArray array];
//    for (int i = 0; i < 20; i++) {
//        NSString *str = [NSString stringWithFormat:@"bb-%d",i];
//        [arr addObject:str];
//    }
//    aaa.selectedTags =arr2;
//    aaa.tagBackgroundColor = [UIColor lightGrayColor];
//    
//    
//    aaa.backgroundColor = [UIColor whiteColor];
//    [self.view addSubview:aaa];
//    
}
-(void)setupUI{
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"aa"];
}
-(void)loadData{
    
    [YDYSearchModel loadSearchWordsWithSuccess:^(NSArray *obj) {
        YDYLog(@"obj")
        for (YDYSearchModel *search in obj) {
            YDYLog(@"%@",search.keyword);
        }
        
    } failure:^(NSError *error) {
        ydy_FailureInView(@"网络错误", self.view);
    }];
////    @"http://s.search.bilibili.com/main/hotword?access_key=ec0f54fc369d8c104ee1068672975d6a&actionKey=appkey&appkey=27eb53fc9058f8c3"
//    
//    [YDYNetWorkTool GET:@"http://s.search.bilibili.com/main/hotword?access_key=ec0f54fc369d8c104ee1068672975d6a&actionKey=appkey&appkey=27eb53fc9058f8c3" parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
//        
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        
//        NSArray *searches = responseObject[@"list"];
//        NSMutableArray *searchModels = [NSMutableArray array];
//        for (NSDictionary *dict in searches) {
//            YDYSearchModel *searchModel = [YDYSearchModel mj_objectWithKeyValues:dict];
//            [searchModels addObject:searchModel];
//        }
//        
//        YDYLog(@"%@",responseObject);
//        YDYWriteToPlist(responseObject, @"search");
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        ydy_FailureInView(@"网络错误", self.view);
//    }];
    
}
- (IBAction)QRBtnClick:(id)sender {
}

- (IBAction)showMoreBtnClick:(id)sender {
}

#pragma mark -
#pragma mark -tableview datasource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 4;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"aa"];
    return cell;
}

@end
